@isTest
public class NoContractApplicationDetailContrlTest
{
    static testMethod void NoContractApplicationDetailContrlTest()
    {
       
        
        //无销售合同仪器后端实施申请
        NoContractInstrumentApplication__c na = new NoContractInstrumentApplication__c();
        insert na;
        //产品线
       ProductStructure__c ps = new ProductStructure__c();
       ps.Classify1__c = 'test';
       insert ps;
        //产品
        Id rid=Utils.getRecordTypeIdByDevNameAndObjName('仪器型号(含竞争对手)','Product__c');
        Product__c p = TestUtils.createInst();
        p.RecordTypeId = rid;
        p.ProductStructure__c = ps.Id;
        insert p;
        
 PageReference page = new PageReference('/apex/NoContractInstrumentApplicationDetail?id=' + na.Id);
  	System.Test.setCurrentPage(page);
    NoContractApplicationDetailController ncd = new NoContractApplicationDetailController(new ApexPages.StandardController(na));
  	ncd.init();
    ncd.name = '自动';
    ncd.search();
     for(NoContractApplicationDetailController.ProductBean pb: ncd.pList){
     	pb.chk = true;
     }
     ncd.exchange();
     NoContractInstrumentApplicationDetail__c nad = ncd.nList[0].nad;
     nad.Calculated__c = '否';
     nad.Remarks__c = '测试';
     ncd.save();
     
     System.assertEquals(1,[select id from NoContractInstrumentApplicationDetail__c where NoContractInstrumentApplication__c =:na.Id].size());
        
    }
}